let init = function mpbUrlInit() {
  let str = this.ourl;
  let parts;
  let i;
  let index;
  let kv;
  index = str.indexOf('?');
  if (index > 0) {
    this.href = str.substring(0, index);
    str = str.substr(index + 1);
    parts = str.split('&');
    for (i = 0; i < parts.length; i++) {
      kv = parts[i].split('=');
      this.params[kv[0]] = kv[1];
    }
  } else {
    this.href = this.ourl;
    this.params = {};
  }
  return this;
}
let MpbUrl = function construct(url) {
  this.ourl = url || window.location.href;
  this.href = ''; // ?前面部分
  this.params = {}; // url参数对象
  return init.call(this);
};
MpbUrl.prototype.get = function getParam(key) { //获取url之后指定的参数对象
  return this.params[key];
};

export default MpbUrl